package scv.relatorio;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;

public class RelProdutoPorEstoque 
{ 
	Connection con;
	
	@SuppressWarnings("unchecked")
	public JasperPrint RelatorioProdutos(String estoqueInicial,String estoqueFinal) 
	throws Exception
	{ JasperPrint rel=null;

	String url = "jdbc:oracle:thin:@127.0.0.1:1521";
    try { 
    	Class.forName("oracle.jdbc.OracleDriver");
    } catch(java.lang.ClassNotFoundException e1) { 
        System.err.print("ClassNotFoundException: "); 
        System.err.println(e1.getMessage()); 
    } 
    try { 
        con = DriverManager.getConnection(url,"SYSTEM", "123456"); 
    } catch(SQLException ex) { 
        System.err.print("SQLException: "); 
        System.err.println(ex.getMessage()); 

    }

    try	{ // Connection con = Conexao.criaConexao(); 
	HashMap map= new HashMap();
	
	map.put("v1",new BigDecimal(estoqueInicial) );
	map.put("v2",new BigDecimal(estoqueFinal));
	
	String arquivoJasper= "C:\\workspace\\SCV\\relatorios\\RelatorioProdutos.jasper"; 
	rel=JasperFillManager.fillReport(arquivoJasper,map,con);
	con.close();
	}
	catch (JRException e)
	{ e.printStackTrace(); 
	} 
	return rel; 
	}
}
